//
// Created by Jisam on 2024/7/23.
//
#include <bits/stdc++.h>

#define PSI pair<string,int>
#define PII pair<int,int>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define i64 long long

using namespace std;

const int N = 1e5 + 5;
int ans;

void solve() {
    int n ,t, p;
    cin >> n >> t >> p;
    vector<int> a(n);
    for(int i = 0 ; i < n ; i ++) cin >> a[i];
    sort(a.begin(),a.end());
//    for(int i = 0 ; i < n ; i ++) cout <<" " << a[i] ;
//    cout << "a[n - p - 1] " << a[n - 1 - (p - 1)];
    if(t - a[n - 1 - (p - 1)] <= 0){
        cout << 0;
    }else cout << t - a[n - 1 - (p - 1)];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) solve();
//    cout << "\n"[];
    return 0;
}